package com.founder.gateway.service.impl;

import java.util.List;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.founder.gateway.orm.fzapi.bean.entity.ApiEntityEntity;
import com.founder.gateway.orm.fzapi.bean.entity.ApiParamEntity;
import com.founder.gateway.orm.fzapi.bean.entity.ApiReturnParamEntity;
import com.founder.gateway.orm.fzapi.bean.entity.ApiSchemeEntity;
import com.founder.gateway.service.ApiService;
import com.founder.gateway.system.bean.CacheStructure;
import com.founder.gateway.system.consts.Consts;

@Service("apiService")
public class ApiServiceImpl implements ApiService {
	@Override
	@Cacheable(value = CacheStructure.FOUNDER_GATEWAY_API_CACHE, key = "'AE_'+#apiId")
	public ApiEntityEntity queryApi(String apiId) {
		ApiEntityEntity apiEntityEntity = new ApiEntityEntity();
		apiEntityEntity.setId(apiId);
		apiEntityEntity.setXtZxbz(Consts.XT_ZXBZ_WZX);
		apiEntityEntity.queryBySelf();
		return apiEntityEntity;
	}

	@Override
	@Cacheable(value = CacheStructure.FOUNDER_GATEWAY_API_CACHE, key = "'AP_'+#apiSchemeId")
	public List<ApiParamEntity> queryApiParam(String apiSchemeId) {
		ApiParamEntity queryEntity = new ApiParamEntity();
		queryEntity.setApiSchemeId(apiSchemeId);
		queryEntity.setXtZxbz(Consts.XT_ZXBZ_WZX);
		return queryEntity.queryListBySelf();
	}

	@Override
	@Cacheable(value = CacheStructure.FOUNDER_GATEWAY_API_CACHE, key = "'SC_'+#apiSchemeId")
	public ApiSchemeEntity queryApiScheme(String apiSchemeId) {
		ApiSchemeEntity apiSchemeEntity = new ApiSchemeEntity();
		apiSchemeEntity.setId(apiSchemeId);
		apiSchemeEntity.setXtZxbz(Consts.XT_ZXBZ_WZX);
		apiSchemeEntity.queryBySelfId();
		return apiSchemeEntity;
	}

	@Override
	@Cacheable(value = CacheStructure.FOUNDER_GATEWAY_API_CACHE, key = "'RP_'+#apiSchemeId")
	public List<ApiReturnParamEntity> queryApiReturnParam(String apiSchemeId) {
		ApiReturnParamEntity queryEntity = new ApiReturnParamEntity();
		queryEntity.setApiSchemeId(apiSchemeId);
		queryEntity.setXtZxbz(Consts.XT_ZXBZ_WZX);
		return queryEntity.queryListBySelf();
	}

}
